Solution to Exercise 2
Solution to exercise 2.
We'll cover the following
Solution#
The ER diagram derived from our requirements is shown below.
Explanation#
In our design:
-
An AIRPLANE is uniquely identified by its
Registration_Num
, so we use this as the primary key. -
A FLIGHT is uniquely identified by its
Flight_Number
, so we use the flight number as the primary key. The departure and destination airports are captured in theFrom
andTo
attributes, and we have separate attributes for the departure and arrival date and time. -
Because no two passengers will share an email address, we can use the
Email_Address
as the primary key for the PASSENGER entity. -
An airplane can be involved in any number of flights, while each flight uses exactly one airplane, so the FLIES relationship between the AIRPLANE and FLIGHT entities has cardinality 1:N; because a flight cannot exist without an airplane, the FLIGHT entity participates totally in this relationship.
-
A passenger can book any number of flights, while a flight can be booked by any number of passengers. We capture this by creating the entity BOOKING which has 1:N relationships between it and the PASSENGER and FLIGHT entities.
With this, the chapter comes to an end. By now we should be familiar with the different components that make up an ER diagram. And how to put them together to make an ER diagram.
In the next chapter, we will tackle the different concepts surrounding the relational database model.